package com.guan.study.easyExcelDemo.write.write03_带图片写;

import com.alibaba.excel.EasyExcel;
import com.guan.study.easyExcelDemo.Student;
import com.guan.study.easyExcelDemo.UserVo;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * @Date: 2023/7/21 14:36
 * @Author: yaobai
 * @Description: 导出图片
 */
public class WriteExcel03 {

    private static final String PATH = "E:\\WorkDirTest2\\";

    public static void main(String[] args) throws MalformedURLException {

        String fileName2 = PATH + System.currentTimeMillis() + "导出图片.xlsx";

        EasyExcel.write(fileName2, UserVo.class)
                .sheet()
                .doWrite(data());

        System.out.println("写入完毕");


    }


    private static List<UserVo> data() throws MalformedURLException {

        List<UserVo> userVos = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            UserVo vo = new UserVo();
            vo.setId("100"+i);
            vo.setUid("ZhangSan_"+i);
            vo.setName("张三"+i);
            vo.setAge(10+i);
            vo.setHeadUrl(new URL("http://www.baidu.com/img/bdlogo.png"));

            userVos.add(vo);
        }

        return userVos;
    }
}
